import { DataType } from "./type";
import type { VarDeclare } from "../data/var_declare";
import type { IDeserializable } from "~/models/serialize/IDeserializable";
import { Deserializer } from "~/models/serialize/Deserializer";
import { Dzer } from "~/models/serialize";

// 定义: 接口类型 (和类型)：
// 不是一种具体的类型，而是类型的类型。在这里定义结构和生成器

export class ChoiceType extends DataType implements IDeserializable {

  className: string = 'ChoiceType'
  static {
  }

  constructor(
    public name: string,
    public options: string[]
  ) {
    super()
  }

  get default(): any {
    return this.options[0]
  }

  receiveType(t: DataType): boolean {
    return t.name === this.name
  }

  override receiveValue(t: any): boolean {
    return this.options.includes(t)
  }
}

